package com.aricksm.xuan.activaty02;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.DatePicker;
import android.widget.ProgressBar;
import android.widget.SeekBar;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.TimePicker;

/**
 * Created by xuan on 16/6/30.
 */
public class Tools extends Activity {

    SeekBar mySeekBar;
    TextView tvSeekBarValue;

    ProgressBar progressBar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tools);

        tvSeekBarValue = (TextView)findViewById(R.id.tv_seek_bar_value);

        mySeekBar = (SeekBar)findViewById(R.id.my_seek_bar);
        mySeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                tvSeekBarValue.setText(String.valueOf(progress -100));
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {

            }
        });

        //// progressBar 的用法 ///
        progressBar = (ProgressBar)findViewById(R.id.progress);
        findViewById(R.id.btn_add).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                progressBar.setProgress(progressBar.getProgress() + 1);
            }
        });
        findViewById(R.id.btn_dec).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                progressBar.setProgress(progressBar.getProgress() - 1);
            }
        });


        DatePicker datePicker = (DatePicker)findViewById(R.id.my_date_picker);
        datePicker.getYear();
        datePicker.getMonth();
        datePicker.getDayOfMonth();

        TimePicker timePicker = (TimePicker)findViewById(R.id.my_time_picker);
        timePicker.getCurrentHour();
        timePicker.getCurrentMinute();


        Spinner spinner = (Spinner) findViewById(R.id.my_spinner);

        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item,
                android.R.id.text1, new String[]{"小学一年级", "小学二年级", "小学三年级"});

        spinner.setAdapter(adapter);
    }

}
